﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Linq;
using VIP.Manager;
using VIP;

public class AudioExample : MonoBehaviour {

    [SerializeField]
    private AudioClip clip;

    private VIPAudio audioManager;

    [SerializeField]
    private Button btn;

    private string id;

    public VIPButton button;



    public Button buttonSigle;

    public Button idsBtn;

    public InputField ifInf;
    public Button idPlayBtn;


	void Start () {
        audioManager = VIPAudio.Instance;
        btn.onClick.AddListener(() =>
        {
            id = audioManager.Play(clip,()=> {
                print("完成:" + id);
            });
            //VIPDelayManager.Instance.AddDelay(3, A, "传输的数据");
        });
        buttonSigle.onClick.AddListener(() =>
        {
            id = audioManager.Play(clip, () =>
            {
                print("完成:"+ id);
            }, true);
        });
        idPlayBtn.onClick.AddListener(() =>
        {
            audioManager.Play(ifInf.text, clip);
        });
        //button.onLong.AddListener(() =>
        //{
        //    print("长按");
        //});
        button.onDouble.AddListener(() =>
        {
            print("双击");
        });
        idsBtn.onClick.AddListener(() =>
        {
            foreach (string id in audioManager.GetIds()) {
                print(id);
            }
        });
    }

    public void A(object data)
    {
        print((string)data);
        audioManager.Stop(id);
    }

}
